import { http } from "@/utils/http";
import type { TableItem } from "../type";

type ResultTable = {
  total?: number;
  data?: Array<any>;
};

//查询SPC指标列表
export const spcqueryList = (data?: object, cb?: (err: any) => any) => {
  return http.request<ResultTable>(
    "post",
    `/operation/api/v1/spcIndicator/queryList`,
    {
      data
    },
    {},
    cb
  );
};

//新增SPC指标设定
export const spcadd = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/add`, {
    data
  });
};

//删除SPC指标设定
export const spcdelete = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/delete`, {
    data
  });
};

//SPC下载模板
export const spcdownloadTemplate = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/downloadTemplate`, {
    data
  });
};

//查询SPC指标详情
export const spcqueryDetail = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/queryDetail`, {
    data
  });
};

//查询SPC指标分析
export const spcquerySpcAnalysis = (data?: object, cb?: (err: any) => any) => {
  return http.request<Array<TableItem>>(
    "post",
    `/operation/api/v1/spcIndicator/querySpcAnalysis`,
    {
      data
    },
    {},
    cb
  );
};

//查询SPC指标分析
export const waterSpcAnalysis = (data?: object, cb?: (err: any) => any) => {
  return http.request<Array<TableItem>>(
    "post",
    `/operation/api/v1/water/testQuality/config/spcAnalysis`,
    {
      data
    },
    {},
    cb
  );
};

//更新SPC指标设定
export const spcupdate = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/update`, {
    data
  });
};

//查询SPC分析结果列表
export const spcIndicatorquerySpcAnalysisResultList = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/querySpcAnalysisResultList`, {
    data
  });
};

//查询SPC批注列表
export const spcNotequeryList = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcNote/queryList`, {
    data
  });
};

//SPC批注-新增
export const spcNoteadd = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcNote/add`, {
    data
  });
};

//分页查询点位信息
export const twinPointpageTwinPoint = (data?: object) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/twinPoint/pageTwinPoint`, {
    data
  });
};

//查询告警数量
export const spcIndicatorqueryResultCount = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/queryResultCount`, {
    data
  });
};

export const queryMeasureList = (data?: object | undefined, cb?: (err: any) => any) =>
  http.request<Array<TableItem>>("post", `/account/api/v1/publish/measure/queryMeasureList`, { data }, { headers: { noLoading: true } }, cb);

// 指标配置查询
export const queryIndicatorConfigList = (params?: object | undefined, cb?: (err: any) => any) =>
  http.request<Array<TableItem>>("get", `/operation/api/v1/indicator/query/all`, { params }, { headers: { noLoading: true } }, cb);

// 新增指标配置
export const addIndicatorConfig = (data?: object | undefined, cb?: (err: any) => any) =>
  http.request("post", `/operation/api/v1/indicator/add`, { data }, { headers: { noLoading: true } }, cb);

// 修改指标配置
export const updateIndicatorConfig = (data?: object | undefined, cb?: (err: any) => any) =>
  http.request("post", `/operation/api/v1/indicator/update`, { data }, { headers: { noLoading: true } }, cb);

// 删除指标配置
export const deleteIndicatorConfig = (params?: object | undefined, cb?: (err: any) => any) =>
  http.request("DELETE", `/operation/api/v1/indicator/delete`, { params }, { headers: { noLoading: true } }, cb);

// 指标矩阵
export const queryIndicatorMatrix = (params?: object | undefined, cb?: (err: any) => any) =>
  http.request<Array<TableItem>>("get", `/operation/api/v1/indicator/query/all/algorithmMatrix`, { params }, { headers: { noLoading: true } }, cb);

//生成相关性分析热力图计算任务水质
export const algorithmcorrelationFactor = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/operation/algorithm/correlationFactor`, {
    data
  });
};

//生成相关性分析热力图计算任务水质2
export const algorithmcorrelationFactorWater = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/operation/algorithm/correlationFactorWater`, {
    data
  });
};

//依据热力图任务uuid计算生成的结果
export const algorithmcacheRedis = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/operation/algorithm/cacheRedis`, {
    data
  });
};

//依据热力图任务uuid计算生成的结果2
export const algorithmcacheRedisWater = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/operation/algorithm/cacheRedisWater`, {
    data
  });
};

// 指标矩阵
export const queryalgorithmMatrixByPathAndSystemCode = (params?: object | undefined, cb?: (err: any) => any) =>
  http.request<Array<TableItem>>(
    "get",
    `/operation/api/v1/indicator/query/algorithmMatrixByPathAndSystemCode`,
    { params },
    { headers: { noLoading: true } },
    cb
  );

//删除批注
export const spcNotedelete = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcNote/delete`, {
    data
  });
};
//修改批注
export const spcNoteupdate = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcNote/update`, {
    data
  });
};

//SPC批注-选择SPC曲线上的数据添加Normal类型的批注
export const spcNoteaddNormalNote = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcNote/addNormalNote`, {
    data
  });
};

//SPC批注-选择SPC曲线上的数据添加Normal类型的批注
export const spcNotetag = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcNote/tag`, {
    data
  });
};

//相关性分析预测
export const algorithmqueryWaterFuture = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/operation/algorithm/queryWaterFuture`, {
    data
  });
};

//查询相关性散点图
export const algorithmSpecialScatterPlot = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/water/algorithmSpecial/ScatterPlot`, {
    data
  });
};

//相关性指标预测线新
export const algorithmqueryWaterFutureNew = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/operation/algorithm/queryWaterFutureNew`, {
    data
  });
};

//按厂区分开spc指标
export const spcIndicatorquerySpcIndicatorTree = (data?: object) => {
  return http.request<ResultTable>("post", `/operation/api/v1/spcIndicator/querySpcIndicatorTree`, {
    data
  });
};
